package practice_0527;

public class practice04 {
    public static void main(String[] args) throws InterruptedException {
        threadState_ threadState = new threadState_();
        threadState.start();
        System.out.println("初始状态是：" + threadState.getState());

        while(Thread.State.TERMINATED != threadState.getState()){
            Thread.sleep(1000);
            System.out.println("运行状态是：" + threadState.getState());
        }
        System.out.println("运行状态是：" + threadState.getState());

    }
}
class threadState_ extends Thread{

    @Override
    public void run() {
        while(true){
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName()+ "状态是："+ Thread.currentThread().getState());
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
            break;
        }
    }
}
